public class IsPalindrome {

    public static boolean solution(String s) {

        int left=0;
        int right=s.length()-1;

        while (left<right){
            while (left<right&&!Character.isLetterOrDigit(s.charAt(left))){
                left++;
            }

            while (left<right&&!Character.isLetterOrDigit(s.charAt(right))){
                right--;
            }

            if(Character.toLowerCase(s.charAt(left))!=Character.toLowerCase(s.charAt(right))){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }

    public static void main(String[] args) {
        solution("A man, a plan, a canal: Panama");
    }
}
